import { registerAs } from '@nestjs/config'

export default registerAs('wechat', () => ({
  // 登录认证配置
  auth: {
    appId: process.env.WECHAT_APP_ID,
    appSecret: process.env.WECHAT_APP_SECRET,
    token: process.env.WECHAT_TOKEN,
    encodingAESKey: process.env.WECHAT_ENCODING_AES_KEY,
    callbackUrl: process.env.WECHAT_CALLBACK_URL || 'http://localhost:3000/auth/wechat/callback',
    scope: 'snsapi_userinfo',
    state: 'STATE',
  },

  // 支付配置
  payment: {
    appId: process.env.WECHAT_APP_ID,
    mchId: process.env.WECHAT_MCH_ID,
    apiKey: process.env.WECHAT_API_KEY,
    notifyUrl: process.env.WECHAT_NOTIFY_URL,
    certPath: process.env.WECHAT_CERT_PATH || '/certs/wechat',
    sandbox: process.env.WECHAT_SANDBOX === 'true',
    signType: 'MD5',
    tradeType: 'JSAPI',
    feeType: 'CNY',
    timeExpire: 7200, // 2小时
    refundNotifyUrl: process.env.WECHAT_REFUND_NOTIFY_URL,
  },

  // 安全配置
  security: {
    ipWhiteList: process.env.WECHAT_IP_WHITE_LIST?.split(',') || [],
    requestTimeout: 5000,
    retryCount: 3,
    alertThreshold: 5,
  },
}))
